<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>提现记录</title>
<link type="text/css" rel="stylesheet" href="css/styleA.css" />
<link type="text/css" rel="stylesheet" href="css/incomeA.css" />
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/jquery.md5A.js"></script>
<script type="text/javascript" src="js/jquery.jsonpA.js"></script>

<script type="text/javascript" src="js/jquery.cookieA.js"></script>
<script type="text/javascript" src="js/pupil-ajaxA.js"></script>
<script type="text/javascript" src="js/bA.js"></script>
<script type="text/javascript" src="js/styleA.js"></script>

</head>

<body>
	<div class="public-top min-cen">
    	<div class="center logo"></div>  <a href="#">注销</a>
    </div>
    <div class="content center public">
   		<div class="menu">
        	<a class="menu-li" href="javascript:;">
            	<span class="menu-title">个人信息</span>
                <span class="menu-min-title">Personal Information</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">咨询管理</span>
                <span class="menu-min-title">Consulting Management</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">预约管理</span>
                <span class="menu-min-title">Booking Management</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">收入记录</span>
                <span class="menu-min-title">Income Record</span>
            </a>
            <a class="menu-li active" href="javascript:;">
            	<span class="menu-title">提现记录</span>
                <span class="menu-min-title">Present Record</span>
            </a>
        </div>
        <div class="puclic-right">
        	<div class="income-top">
            	<div class="income-title">可提现金额：<span class="blue" id="unWithDrawedMoney">￥4500.99</span></div>
                <div class="income-title">不可提现金额：<span class="red" id="withDrawedMoney">￥4400.00</span></div>
                <a class="income-but" href="javascript:;" id="drawMoneyBtn">提现</a>
                <span class="prompt">提现成功后，1-.3个工作日到账</span>
            </div>
        	<div class="center-frame withdrawal">
            	<div class="income-head icon-head">
                	<span class="month">提现月份</span>
                    <span class="money">操作金额</span>
                    <span class="status">操作现状</span>
                    <span class="time">提现时间</span>
                </div>
                <div class="income-body" id="moneyLogList">
                	<div class="income-li">
                    	<span class="month">2016年4月</span>
                        <span class="money">提现<span class="blue">￥400</span></span>
                        <span class="status">交易成功</span>
                        <span class="time">今天<br/>14:23</span>
                    </div>
					 
                </div>
                <div class="page">
                    <div class="page-right">
                        <a id="moneyLogListPre" style="display:none">上一页</a>
                        <a class="active" id="moneyLogListNext">下一页</a> 
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="window income-no" style=" display:none;">
        <div class="window-bg"></div>
        <div class="window-frame clear">
            <div class="window-out">X</div>
            <div class="income-body">
                <div class="income-no-li clear">
                    <span class="label">提取月份</span>
                    <select class="select" name="" id="income-no-month">
                    </select>
                    <span class="prompt">提示： 可提现￥0.00</span>
                </div>
                <div class="income-no-li clear">
                    <span class="label">未添加银行卡</span>
                </div>
                <div class="income-bank">
                    <div class="income-bank-prompt">无法提现</div>
                    <div class="income-bank-li">
                        <div class="income-bank-img"><img src="images/admin/icon/zfb.png" alt="" /></div>
                        <span class="income-bank-title">支付宝</span>
                        <a class="income-bank-binding" id="zhifubaoBtn">绑定</a>
                    </div>
                    <div class="income-bank-li">
                        <div class="income-bank-img"><img src="images/admin/icon/wx.png" alt="" /></div>
                        <span class="income-bank-title">微信支付</span>
                        <a class="income-bank-binding" id="weixinBtn">绑定</a>
                    </div>
                    <div class="income-bank-li">
                        <span class="income-bank-add">+</span>
                        <span class="income-bank-title">银行卡</span>
                        <a class="income-bank-binding" id="yinhangkaBtn">绑定</a>
                    </div>
                    <div class="income-but-box">
                        <span class="income-but-out">取消</span>
                        <span class="income-but-add">立即添加</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="window weixin"  id ="weixinWin"style=" display:none;">
        <div class="window-bg"></div>
        <div class="window-frame clear">
            <div class="window-out">X</div>
            <div class="weixin-body">
                <div class="weixin-title">绑定微信</div>
                <div class="weixin-li">
                    <span>账号名：</span>
                    <input class="" type="text" name="" value="" id="weixinName" />
                </div>
                <div class="weixin-li">
                    <span>支付账号：</span>
                    <input class="" type="text" name="" value="" id="weixinNo" />
                </div>
                <div class="weixin-but">
                    <span class="out">取消</span>
                    <span class="determine" id="weixinblondBtn">确定</span>
                </div>
            </div>
        </div>
    </div>
    <div class="window weixin" id="zhifubaoWin" style=" display:none;">
        <div class="window-bg"></div>
        <div class="window-frame clear">
            <div class="window-out">X</div>
            <div class="weixin-body">
                <div class="weixin-title">绑定支付宝</div>
                <div class="weixin-li">
                    <span>账号名：</span>
                    <input class="" type="text" name="" value="" id="zhifubaoName" />
                </div>
                <div class="weixin-li">
                    <span>支付账号：</span>
                    <input class="" type="text" name="" value="" id="zhifubaoNo" />
                </div>
                <div class="weixin-but">
                    <span class="out">取消</span>
                    <span class="determine" id="zhifubaoblondBtn" >确定</span>
                </div>
            </div>
        </div>
    </div>
    <div class="window bank-add" style=" display:none;">
        <div class="window-bg"></div>
        <div class="window-frame clear">
            <div class="window-out">X</div>
            <div class="bank-add-frame">
                <div class="title">添加银行卡</div>
                <div class="bank-add-li">
                    <div class="frame">
                        <span class="label">持卡人：</span>
                        <input class="input" name="" value="" id="pname" />
                    </div>
                    <span class="id-num">身份证：3202344534443333232</span>
                </div>
                <div class="bank-add-li">
                    <span class="text">请绑定持卡人的银行卡</span>
                </div>
                <div class="bank-add-li">
                    <div class="bank-add-box">
                        <div class="input-box">
                            <span class="label">银行：</span>
                            <select class="select"   id = "bankName">
                                <option value="中国银行">中国银行</option>
                                <option value="建设银行">建设银行</option>
                            </select>
                        </div>
                        <div class="input-box">
                            <span class="label">省份城市：</span>
                            <select class="select" name="" id="city">
                                <option value="">江苏省南京市</option>
                            </select>
                        </div>
                    </div>
                    <div class="bank-add-box">
                        <div class="input-box">
                            <span class="label">开户行：</span>
                            <input class="input" type="text" name="" value="" id="bankDetail"/>
                        </div>
                        <div class="input-box">
                            <span class="label">卡号：</span>
                            <input class="input" type="text" name="" value=""  id="bankNo"/>
                        </div>
                    </div>
                    <div class="bank-add-but-box">
                        <span class="bank-add-but-out">取消</span>
                        <span class="bank-add-but-add" id="bankAddBtn">确认</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="window income-choose" style=" display:none;">
        <div class="window-bg"></div>
        <div class="window-frame clear">
            <div class="window-out">X</div>
            <div class="income-body">
                <div class="income-choose-li clear">
                    <span class="label">提取时间</span>
                    <select class="select" name="" id="income_month">
                    </select>
                    <span class="prompt">提示： 可提现￥0.00</span>
                </div>
                <div class="income-choose-li clear">
                    <span class="label">已添加账户</span>
                </div>
                <div class="income-bank" id="weixin_zhifubao">
                    <!--<div class="income-bank-li">-->
                        <!--<div class="income-bank-img"><img src="images/icon/zfb.png" alt="" /></div>-->
                        <!--<span class="income-bank-title">支付宝</span>-->
                        <!--<span class="income-bank-user">账号  15xxxxxx343</span>-->
                        <!--<input class="income-bank-checkbox" type="checkbox" name="" value="" />-->
                    <!--</div>-->
                    <!--<div class="income-bank-li">-->
                        <!--<span class="income-bank-add">+</span>-->
                        <!--<span class="income-bank-title">微信</span>-->
                    <!--</div>-->
                </div>
                <div class="income-choose-li clear">
                    <span class="label">已有银行卡</span>
                </div>
                <div class="income-bank" id="bankCard">
                    <div class="income-bank-li">
                        <div class="income-bank-img"><img src="images/admin/icon/jsBank.png" alt="" /></div>
                        <span class="income-bank-title">建设银行</span>
                        <span class="income-bank-user">尾号  3443</span>
                        <input class="income-bank-checkbox" type="checkbox" name="" value="" />
                    </div>
                </div>
                <div class="income-bank">
                    <div class="income-bank-li">
                        <span class="income-bank-add">+</span>
                        <span class="income-bank-title">其他银行</span>
                    </div>
                    <div class="income-but-box">
                        <span class="income-but-out bankOut">取消</span>
                        <span class="income-but-add">确认</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <input type = "hidden" value = "" id="withDrawDate"/>
	<script> 
		$(function(){ 
			getMoneyLogList(1,null);
			$("#moneyLogListPre").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)-1);
				getMoneyLogList(page,null);
			});
			$("#moneyLogListNext").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)+1);
				getMoneyLogList(page,null);
			});
			
			$("#moneyLogListSearch").click(function(){
				var searchStr = $("#searchStr").val(); 
				getMoneyLogList(1,searchStr);
			});
            //提现按钮
            $("#drawMoneyBtn").click(function(){
                var expertId = $.cookie("expertId");
                ajaxPostJson(requestUrl + "/emoney/getDrawableMonthAndAccountX", function(data, status){
                    eval("rt=" + data);
                    if (rt.error!="") {
                        alert(rt.error);
                    }else{
                        var accountList =  rt.accountList;
                        var monthList = rt.monthList;
                        var htmlStr ="";
                        if(monthList!=null){ //判断可提现月份是否存在
                            $("#income_month").html('');
                            $.each(monthList,function(month){
                                var list=monthList[month];
                                $(".income-body .prompt").html("提示： 可提现￥"+list.withDrawMoney);
                                $("#income_month").append("<option value=\""+list.month+"\">"+list.month+"</option>") ;
                            });
                            $.each(monthList,function(month){
                                var list=monthList[month];
                                $(".income-body .prompt").html("提示： 可提现￥"+list.withDrawMoney);
                                $("#income-no-month").append("<option value=\""+list.month+"\">"+list.month+"</option>") ;
                            });
                        }
                        if(typeof(accountList)!="undefined" && accountList!=null){//存在提现账户信息
                            var htmlStr = "";
                            $.each(accountList,function(account){
                                var list=accountList[account];
                                $("#bankCard").html('');
                                $("#weixin_zhifubao").html('');
                                if(list.accountType==1 || list.accountType == 2){
                                    $("#weixin_zhifubao").append("<div class=\"income-bank-li\">"
                                            +"<div class=\"income-bank-img\"><img src=\"\" alt=\"\" /></div>"
                                            +"<span class=\"income-bank-title\">"+getaccountType(list.accountType)+"</span>"
                                            +"<span class=\"income-bank-user\" >账号  "+list.account+"</span>"
                                            +"<input class=\"income-bank-checkbox\" type=\"checkbox\" name=\"\" account=\""+list.account+"\" value=\""+list.accountId+"\" />"
                                            +"</div>") ;
                                }else{
                                    $("#bankCard").append("<div class=\"income-bank-li\">"
                                            +"<div class=\"income-bank-img\"><img src=\"\" alt=\"\" /></div>"
                                            +"<span class=\"income-bank-title\">"+getaccountType(list.accountType)+"</span>"
                                            +"<span class=\"income-bank-user\" >账号  "+list.account+"</span>"
                                            +"<input class=\"income-bank-checkbox\" type=\"checkbox\" name=\"accountCheck\" account=\""+list.account+"\" value=\""+list.accountId+"\" />"
                                            +"</div>") ;
                                }
                                $(".income-choose").fadeIn();
                            });
                            $('.window .income-choose').fadeIn();
                        }else{//不存在体现账号信息 则 新增账号
                            $('.income-no').fadeIn();
                        }
                    }
                }, {"from":"expert","expertId":expertId,"debug":1});


            });
            $("#zhifubaoBtn").click(function(){
                $('#zhifubaoWin').fadeIn();
            });
            $(".bank-add-but-out").click(function(){
                $(".bank-add").fadeOut();
            });
            $("#weixinBtn").click(function(){
                $('#weixinWin').fadeIn();
            });

            $("#yinhangkaBtn").click(function(){
                $('.window.bank-add').fadeIn();
            });
            //添加银行卡
            $("#bankAddBtn").click(function(){
                console.log("银行卡");
                var accountType = 3;
                var cardOwner = $("#pname").val();
                var bankName=$("#bankName").val();
                var bankCity=$("#city").val();
                var bankAddress=$("#bankDetail").val();
                var account= $("#bankNo").val();
                var expertId = $.cookie("expertId");
                var id=$("idno").val();
                ajaxPostJson(requestUrl + "/eaccount/addAccountX", function(data, status){
                    eval("rt=" + data);
                    if (rt.error!="") {
                        alert(rt.error);
                    }else{
                        alert("保存成功！");
                        $('.window.bank-add').fadeIn();
                    }

                },{"from":"expert","accountType":accountType,"account":account,"bankName":bankName,
                    "bankCity":bankCity,"bankAddress":bankAddress,"cardOwner":cardOwner,"ID":"","expertId":"1","debug":1});
            });
            //添加支付宝
            $("#zhifubaoblondBtn").click(function(){
                console.log("支付宝");
                var accountType =1;
                var cardOwner = $("#zhifubaoName").val();
                var account = $("#zhifubaoNo").val();
                ajaxPostJson(requestUrl + "/eaccount/addAccountX", function(data, status){
                    eval("rt=" + data);
                    if (rt.error!="") {
                        alert(rt.error);
                    }else{
                        alert("保存成功！");
                        $('#zhifubaoWin').fadeIn();
                    }

                },{"from":"expert","accountType":accountType,"account":account,"cardOwner":cardOwner,"ID":"","expertId":"1","debug":1});
            });
            //添加微信支付
            $("#weixinblondBtn").click(function(){
                alert("微信");
                var accountType =2;
                var cardOwner = $("#weixinname").val();
                var account = $("#weixinNo").val();
                ajaxPostJson(requestUrl + "/eaccount/addAccountX", function(data, status){
                    eval("rt=" + data);
                    if (rt.error!="") {
                        alert(rt.error);
                    }else{
                        alert("保存成功！");
                        $('#weixinWin').fadeIn();
                    }

                },{"from":"expert","accountType":accountType,"account":account,"cardOwner":cardOwner,"ID":"","expertId":"1","debug":1});

            });
//            确认提现
            $(".income-but-add").each(function(){
                $(this).click(function(){
                    if($(this).html()=="确认"){
                        ajaxPostJson(requestUrl + "/emoney/withDrawMoneyA", function(data, status){
                            eval("rt=" + data);
                            if (rt.error!="") {
                                alert(rt.error);
                            }else{
                                alert("申请提现成功！");
                                $('.window.bank-add').fadeIn();
                            }
                        },{"from":"expert","expertId":"1","debug":1,"monthStr":$("#income_month").val(),"accountId":"5",})
                    }
                });
            });
            $(".bankOut").click(function(){
                $(".income-choose").fadeOut();
            });
		});
		
		//获取未接单预约咨询订单
		function getMoneyLogList(page,desc){
			var expertId = $.cookie("expertId");
			ajaxPostJson(requestUrl + "/emoney/getMoneyLogListA", function(data, status){
				eval("rt=" + data);
				if (rt.error!="") {
					$("#moneyLogListNext").css("display","none");
					alert(rt.error);
				}else{ 
					var drawList =  rt.logList;
					var unWithDrawedMoney = rt.unWithDrawedMoney;
					var withDrawedMoney =rt.withDrawedMoney;
					$("unWithDrawedMoney").html(unWithDrawedMoney);
					$(withDrawedMoney).html(withDrawedMoney);
					var htmlStr ="";
					if(typeof(drawList)!="undefined"){
						$.each(drawList,function(draw){
						    var list=drawList[draw];
						htmlStr+= "<div class=\"income-li\">"
								+"<span class=\"month\">"+list.addTime+"</span>"
								+"<span class=\"money\">提现<span class=\"blue\">￥"+list.money+"</span></span>"
								+"<span class=\"status\">"+getDrawStatus(list.status)+"</span>"
								+"<span class=\"time\">"+list.addTime+"</span>"
								+"</div>";
						}); 
					}
					$("#moneyLogList").html(htmlStr);
                    setMenuHeight();
				}
			}, {"from":"expert","currentpage":page,"desc":desc,"expertId":expertId,"debug":1});
		}
		
		function getDrawStatus(status){
			var status=status;
			if(status=="1"){
                status="提现中";
			}else if(status==2){
                status="已提现";
			}else{
                status="提现失败";
            }
			return status;
		}
        function getaccountType(accountType){
            if(accountType==1){
                return "支付宝";
            }else if(accountType==2){
                return "微信";
            }else{
                return "银行卡";
            }
        }
        $(".income-body .income-bank-li").each(function(){
            $(this).click(function(){
                if($(this).find(".income-bank-title").html().indexOf("支付宝")!==-1){
                    $("#zhifubaoWin").fadeIn();
                    $(".income-choose").fadeOut();
                }else if($(this).find(".income-bank-title").html().indexOf("微信")!==-1){
                    $("#weixinWin").fadeIn();
                    $(".income-choose").fadeOut();
                }else if($(this).find(".income-bank-title").html().indexOf("银行")!==-1){
                    $(".bank-add").fadeIn();
                    $(".income-choose").fadeOut();
                }
            });
        });
        function setMenuHeight(){
            $(".content >.menu").css("height",$('.content').css('height'));
        }
	</script> 
</body>
</html>
